import { AxiosResponse } from "axios";

const errorCode = (response: AxiosResponse): string => {
  /** http status code */
  const code = response.status;
  /** notice text */
  let message = "Request Error";
  switch (code) {
    case 400:
      message = "Request Error";
      break;
    case 401:
      message = "Unauthorized, please login";
      break;
    case 403:
      message = "拒绝访问";
      break;
    case 404:
      message = "访问资源不存在";
      break;
    case 408:
      message = "请求超时";
      break;
    case 500:
      message = "位置错误";
      break;
    case 501:
      message = "承载服务未实现";
      break;
    case 502:
      message = "网关错误";
      break;
    case 503:
      message = "服务暂不可用";
      break;
    case 504:
      message = "网关超时";
      break;
    case 505:
      message = "暂不支持的 HTTP 版本";
      break;
    default:
      message = "位置错误";
  }
  return message;
};
export default errorCode;
